package com.sibbay.vta.adaptor;

import com.sibbay.vta.adaptor.TimeListAdapter.FindBestTimePosition;

import android.test.AndroidTestCase;

public class TimeListAdapterTest extends AndroidTestCase {

	private static final String[] sTimeTable1 = {
		// 0         1         2         3      
		"08:29P", "11:00P", "11:30P", "12:31A", 
	};

	public void testFindBestTimePosition1() {
    	FindBestTimePosition.setArray(sTimeTable1);

		assertEquals("time pos", 0,  FindBestTimePosition.findPosition("01:00A"));
		assertEquals("time pos", 0,  FindBestTimePosition.findPosition("08:00P"));
		assertEquals("time pos", 1,  FindBestTimePosition.findPosition("08:30P"));
		assertEquals("time pos", 1,  FindBestTimePosition.findPosition("11:00P"));
		assertEquals("time pos", 3,  FindBestTimePosition.findPosition("12:02A"));
		assertEquals("time pos", 0,  FindBestTimePosition.findPosition("05:02P"));
		assertEquals("time pos", 3,  FindBestTimePosition.findPosition("12:30A"));
		assertEquals("time pos", -1, FindBestTimePosition.findPosition("12:42A"));
	}

	private static final String[] sTimeTable2 = {
		// 0         1      
		"11:30P", "12:31A", 
	};
	
	public void testFindBestTimePosition2() {
    	FindBestTimePosition.setArray(sTimeTable2);

		assertEquals("time pos", 0,  FindBestTimePosition.findPosition("08:30A"));
		assertEquals("time pos", 0,  FindBestTimePosition.findPosition("08:30P"));
		assertEquals("time pos", 0,  FindBestTimePosition.findPosition("11:00P"));
		assertEquals("time pos", 1,  FindBestTimePosition.findPosition("12:02A"));
		assertEquals("time pos", 0,  FindBestTimePosition.findPosition("05:02P"));
		assertEquals("time pos", 1,  FindBestTimePosition.findPosition("12:30A"));
		assertEquals("time pos", -1, FindBestTimePosition.findPosition("12:42A"));
	}
}
